<%
    can_add_event = can_add_event?(@ecase)
    can_edit_event = can_edit_event?(@ecase)
    can_delete_event = can_delete_event?(@ecase)
    colspan = 1 + bool_to_int(can_edit_event) + bool_to_int(can_delete_event) 
%>
<h1 class="library_title">Listing events</h1>
<div class="horizontal_line"></div>
<%= h_spacer 20 %>
<table class="admin" >
  <tr>
    <th> Title </th>
    <th> Created at</th>
    <th> Updated at</th>
    <th colspan="<%= colspan %>" >Actions</th>
  </tr>
  
<% for event in @events %>
  <tr>
    <td><%=h event.title %></td>
    <td><%=date_format event.created_at %></td>
    <td><%=date_format event.updated_at %></td>
    <td><%= link_to('Show', :action => 'show', :id => event) %></td>
    <% if can_edit_event %>
    <td><%= link_to('Edit', :action => 'edit', :id => event) %></td>
    <% end %>
    <% if can_delete_event %>
    <td><%= link_to('Destroy', { :action => 'destroy', :id => event }, :confirm => 'Are you sure?', :post => true) %></td>
    <% end %>
  </tr>
<% end %>
</table>
<p>
<%= link_to 'Previous page', { :page => @event_pages.current.previous } if @event_pages.current.previous %>
<%= link_to 'Next page', { :page => @event_pages.current.next } if @event_pages.current.next %> 
</p>
<%= h_spacer 10 %>
<% if can_add_event %>
<p><%= link_to('New event', :action => 'new', :id => @ecase.id) %></p>
<% end %>